package com.nopay.dxdwphone.ui.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
import com.nopay.dxdwphone.R;

public class DialKeyboardAdapter extends BaseAdapter {

    private final String[] KEYBOARD_CHAR = {"1", "2", "3", "4", "5", "6", "7", "8", "9", "*", "0", "#"};

    private final LayoutInflater mInflater;

    public DialKeyboardAdapter(Context context) {
        super();
        mInflater = LayoutInflater.from(context);
    }

    @Override
    public int getCount() {
        return KEYBOARD_CHAR.length;
    }

    @Override
    public String getItem(int position) {
        return KEYBOARD_CHAR[position];
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder;
        if(convertView == null) {
            holder = new ViewHolder();
            convertView = mInflater.inflate(R.layout.item_dial_keyboard, null);
            holder.tv_keyboard_char = convertView.findViewById(R.id.tv_keyboard_char);

            convertView.setTag(holder);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }

        holder.tv_keyboard_char.setText(getItem(position));
        return convertView;
    }

    public static class ViewHolder {
        private TextView tv_keyboard_char;
    }
}
